/*------------------------------------------------------------------------
//                          Project CommonLib                           //
------------------------------------------------------------------------*/

#pragma once

#define CmASSERTFAIL_D()									CmASSERT(0)    
#define CmASSERT_MSG_D( exp, format, ...)					AssertMsg( exp, TEXT(#exp), __LINE__, __FUNCTIONW__, TEXT(__FILE__), format, __VA_ARGS__)
#define CmASSERTFAIL_MSG_D( format, ...)					AssertFailMsg( __LINE__, __FUNCTIONW__, TEXT(__FILE__), format, __VA_ARGS__)

#define CmVERIFY_D( expr )								{ if( !(expr) ){ CmASSERT((expr)); } }
#define CmVERIFY_RETURN_VALUE_D( exp, returnValue )		{ if( !(exp) ){ CmASSERT(exp); return returnValue; } }
#define CmVERIFY_RETURN_D( exp )							{ if( !(exp) ){ CmASSERT(exp); return; } }


//////////////////////////////////////////////////////////////////////////
// Release
#define CmASSERT_R( exp )								{if( FALSE==(exp) ) { __LOG( TEXT("CmASSERT %s %d\n"), __FUNCTIONW__, __LINE__);} }
#define CmASSERTFAIL_R()								{ __LOG( TEXT("CmASSERTFAIL %s %d\n"), __FUNCTIONW__, __LINE__);}
#define CmASSERT_MSG_R( exp, format, ...)				{if( FALSE==(exp) ) { __LOG(TEXT("CmASSERT_MSG %s %d\n"), __FUNCTIONW__, __LINE__);__LOG(format, __VA_ARGS__); }}
#define CmASSERTFAIL_MSG_R( format, ...)				{ __LOG(TEXT("CmASSERTFAIL_MSG %s %d\n"), __FUNCTIONW__, __LINE__);__LOG(format, __VA_ARGS__); }

#define CmVERIFY_R(expr)								{if( FALSE==(expr) ) {__LOG(TEXT("CmVERIFY %s %d\n"), __FUNCTIONW__, __LINE__);} }
#define CmVERIFY_RETURN_VALUE_R( exp, returnValue )		{if( !(exp) ){ __LOG(TEXT("CmVERIFY_R_V %s %d\n"), __FUNCTIONW__, __LINE__); return returnValue; } }
#define CmVERIFY_RETURN_R( exp )						{if( !(exp) ){ __LOG(TEXT("CmVERIFY_R %s %d\n"), __FUNCTIONW__, __LINE__ ); return; } }


//////////////////////////////////////////////////////////////////////////
// shipping
#define CmASSERT_S( exp )
#define CmASSERTFAIL_S()
#define CmASSERT_MSG_S( exp, format, ...)
#define CmASSERTFAIL_MSG_S( format, ...)
#define CmVERIFY_S(expr)
#define CmVERIFY_RETURN_VALUE_S( exp, returnValue )		{if( !(exp) ){ return returnValue; } }
#define CmVERIFY_RETURN_S( exp )						{if( !(exp) ){ return; } }

#ifdef _DEBUG
	#define CmASSERT				CmASSERT_D
	#define CmASSERTFAIL			CmASSERTFAIL_D
	#define CmASSERT_MSG			CmASSERT_MSG_D
	#define CmASSERTFAIL_MSG		CmASSERTFAIL_MSG_D

	#define CmVERIFY				CmVERIFY_D
	#define CmVERIFY_RETURN_VALUE	CmVERIFY_RETURN_VALUE_D
	#define CmVERIFY_RETURN			CmVERIFY_RETURN_D
#else _SHIPPING
	#define CmASSERT				CmASSERT_S
	#define CmASSERTFAIL			CmASSERTFAIL_S
	#define CmASSERT_MSG			CmASSERT_MSG_S
	#define CmASSERTFAIL_MSG		CmASSERTFAIL_MSG_S
	#define CmVERIFY				CmVERIFY_S
	#define CmVERIFY_RETURN_VALUE	CmVERIFY_RETURN_VALUE_S
	#define CmVERIFY_RETURN			CmVERIFY_RETURN_S
//#else	//release
//	#define CmASSERT				CmASSERT_R
//	#define CmASSERTFAIL			CmASSERTFAIL_R
//	#define CmASSERT_MSG			CmASSERT_MSG_R
//	#define CmASSERTFAIL_MSG		CmASSERTFAIL_MSG_R
//	#define CmVERIFY				CmVERIFY_R
//	#define CmVERIFY_RETURN_VALUE	CmVERIFY_RETURN_VALUE_R
//	#define CmVERIFY_RETURN			CmVERIFY_RETURN_R
#endif


#define __LOG CmTRACE

/*------------------------------------------------------------------------

------------------------------------------------------------------------*/